﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MRSUtil;

namespace MRS.DBL.BLL
{
    public class RoleMgr
    {

        private DAL.RoleDAL _roleDAL = new DAL.RoleDAL();

        /// <summary>
        /// 判断是否存在
        /// </summary>
        public bool ExistsRole(string roleName)
        {
            return _roleDAL.Exists(roleName);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int AddRole(MRS.DBL.Model.RoleModel model)
        {
            if (ExistsRole(model.Role))
                return MRSConsts.Code_Exists;
            return _roleDAL.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool UpdateRoleInfo(MRS.DBL.Model.RoleModel model)
        {
            return _roleDAL.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool DeleteRole(int Id)
        {
            return _roleDAL.Delete(Id);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MRS.DBL.Model.RoleModel GetRoleModel(int Id)
        {
            return _roleDAL.GetModel(Id);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public MRS.DBL.Model.RoleModel[] GetRoleList()
        {
            return _roleDAL.GetList();
        }
    }
}
